<!DOCTYPE html>
<html>
  <head>
    <title>Listing 5.12</title>
    <script type="text/javascript" src="../scripts/assert.js"></script>
    <link href="../styles/assert.css" rel="stylesheet" type="text/css">
  </head>
  <body>
    <script type="text/javascript">

			Function.prototype.partial = function() {
			  var fn = this, args = Array.prototype.slice.call(arguments);
			  return function() {
			    var arg = 0;
			    for (var i = 0; i < args.length && arg < arguments.length; i++) {
			      if (args[i] === undefined) {
			        args[i] = arguments[arg++];
			      }
			    }
			    return fn.apply(this, args);
			  };
			};

			Math.maxAbove500 = Math.max.partial(500);

      assert(Math.maxAbove500(3,4,1,6) == 500, "Max of 500, 3, 4, 1, 6 is 500"); //#4
      assert(Math.maxAbove500(3,4,11223,1,6) == 11223, "Max of 500, 3, 4, 11223, 1, 6 is 11223");      //#4

    </script>
  </body>
</html>
